package com.eastfair.auth.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.auth.enumeration.OrganizationOrgTypeEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 
 * </p>
 *
 * @author ligang
 * @since 2021-08-30
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("c_organization")
@ApiModel(value = "Organization", description = "")
@AllArgsConstructor
public class Organization extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 组织名称
     */
    @ApiModelProperty(value = "组织名称")
    @Size(max = 255, message = "组织名称长度不能超过255")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "组织名称")
    private String name;

    /**
     * 组织类型#{project:项目;p_company_classify:项目下的公司分类;p_sponsor_classify:项目下的主办分类;p_audience_classify:项目下的观众分类;exhibition:展会;e_company_classify:展会下的公司分类;e_sponsor_classify:展会下的主办;e_audience_classify:展会下的观众分类;company_classify:公司组;company:公司;sponsor_classify:主办组;sponsor:主办;staff:员工;other:其他}
     */
    @ApiModelProperty(value = "组织类型#{project:项目;p_company_classify:项目下的公司分类;p_sponsor_classify:项目下的主办分类;p_audience_classify:项目下的观众分类;exhibition:展会;e_company_classify:展会下的公司分类;e_sponsor_classify:展会下的主办;e_audience_classify:展会下的观众分类;company_classify:公司组;company:公司;sponsor_classify:主办组;sponsor:主办;staff:员工;other:其他}")
    @TableField(value = "org_type")
    @Excel(name = "组织类型#{project:项目;p_company_classify:项目下的公司分类;p_sponsor_classify:项目下的主办分类;p_audience_classify:项目下的观众分类;exhibition:展会;e_company_classify:展会下的公司分类;e_sponsor_classify:展会下的主办;e_audience_classify:展会下的观众分类;company_classify:公司组;company:公司;sponsor_classify:主办组;sponsor:主办;staff:员工;other:其他}", replace = {"项目_PROJECT", "项目下的公司分类_P_COMPANY_CLASSIFY", "项目下的主办分类_P_SPONSOR_CLASSIFY", "项目下的观众分类_P_AUDIENCE_CLASSIFY", "展会_EXHIBITION", "展会下的公司分类_E_COMPANY_CLASSIFY", "展会下的主办_E_SPONSOR_CLASSIFY", "展会下的观众分类_E_AUDIENCE_CLASSIFY", "公司组_COMPANY_CLASSIFY", "公司_COMPANY", "主办组_SPONSOR_CLASSIFY", "主办_SPONSOR", "员工_STAFF", "其他_OTHER",  "_null"})
    private OrganizationOrgTypeEnum orgType;

    /**
     * 组织code码
     */
    @ApiModelProperty(value = "组织code码")
    @Size(max = 255, message = "组织code码长度不能超过255")
    @TableField(value = "code", condition = LIKE)
    @Excel(name = "组织code码")
    private String code;

    /**
     * 父级id
     */
    @ApiModelProperty(value = "父级id")
    @TableField(value = "parent_id")
    @Excel(name = "父级id")
    private Long parentId;

    /**
     * 项目id（分库分表用）
     */
    @ApiModelProperty(value = "项目id（分库分表用）")
    @TableField(value = "project_id")
    @Excel(name = "项目id（分库分表用）")
    private Long projectId;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sequence")
    @Excel(name = "排序")
    private Integer sequence;

    /**
     * 是否生效(默认1：可用 0:不可用)
     */
    @ApiModelProperty(value = "是否生效(默认1：可用 0:不可用)")
    @TableField(value = "is_enabled")
    @Excel(name = "是否生效(默认1：可用 0:不可用)")
    private Integer isEnabled;

    /**
     * 是否删除(默认0：未删除 1:已删除)
     */
    @ApiModelProperty(value = "是否删除(默认0：未删除 1:已删除)")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除(默认0：未删除 1:已删除)")
    private Integer isDeleted;


    @Builder
    public Organization(Long id, LocalDateTime createTime, Long createdBy, LocalDateTime updateTime, Long updatedBy, 
                    String name, OrganizationOrgTypeEnum orgType, String code, Long parentId, Long projectId, 
                    Integer sequence, Integer isEnabled, Integer isDeleted) {
        this.id = id;
        this.createTime = createTime;
        this.createdBy = createdBy;
        this.updateTime = updateTime;
        this.updatedBy = updatedBy;
        this.name = name;
        this.orgType = orgType;
        this.code = code;
        this.parentId = parentId;
        this.projectId = projectId;
        this.sequence = sequence;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
    }

}
